#ifndef BALLJOYSTICK_H
#define BALLJOYSTICK_H

#include <QWidget>
#include <QMouseEvent>

namespace Ui {
class BallJoyStick;
}

class BallJoyStick : public QWidget
{
    Q_OBJECT

public:
    explicit BallJoyStick(int width, QWidget *parent = 0);
    ~BallJoyStick();

public:
    double getX();
    double getY();

protected:
    void paintEvent(QPaintEvent *);
    void mousePressEvent(QMouseEvent *e);       //--鼠标按下事件
    void mouseMoveEvent(QMouseEvent *e);    //--鼠标移动事件
    void mouseReleaseEvent(QMouseEvent *e); //--鼠标释放（松开）事件
    void mouseDoubleClickEvent(QMouseEvent *e); //--鼠标双击事件

private:
    int showText();


private:
    Ui::BallJoyStick *ui;
    int zeroX;
    int zeroY;
    int currentX;
    int currentY;
    double validRadius;
    double mouseRadius;
};

#endif // BALLJOYSTICK_H
